
using UnityEngine;
using UnityEngine.UI;

public class Stone : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    Vector3 dir;
    Image img;
    public float hitTime;
    Color[] colorarr={Color.red,Color.blue,Color.green,Color.yellow};
    float flySpeed;
    void Start()
    {
        img=GetComponent<Image>();
        img.color=colorarr[Random.Range(0,4)];
        
        float offset=GameManager.I.currLevel.levelSpeed*hitTime;
        Vector3 target=Bubble.I.transform.position+new Vector3(offset,0,0);
        Vector3 dis=target-transform.position;
        transform.right=dis.normalized;
        dir=(dis).normalized;
        flySpeed=dis.magnitude/hitTime;
    }

    // Update is called once per frame
    void Update()
    {
        print(dir);
        transform.position+=dir*flySpeed*Time.deltaTime;
    }
}
